;(function(){
  'use strict';
  angular.module('controllers.oldOMDisplay.upayQM')
  .controller('billResultCtrl', billResultCtrl);

  function billResultCtrl($scope,COREDATA,UpayBillResultSelecotor,UpayBillResultQueryParam,UpayBillResultViewObj){
    $scope.selector = UpayBillResultSelecotor.setSelector();
    $scope.billResult = UpayBillResultQueryParam.initParam();
    $scope.date = UpayBillResultQueryParam.initDate();
    $scope.flag = UpayBillResultQueryParam.initFlag();
    $scope.viewObj = UpayBillResultViewObj.initViewObj();
    $scope.billResultQuery = UpayBillResultQueryParam.billResultQueryFn;
    $scope.exportUrl = COREDATA.FORMPREFIX+'OMdisplay/upayQM/businessForm/billResult/export';
    $scope.resetParam = function(){
      $scope.billResult = UpayBillResultQueryParam.initParam();
      $scope.date = UpayBillResultQueryParam.initDate();
      $scope.flag = UpayBillResultQueryParam.initFlag();
      $scope.viewObj = UpayBillResultViewObj.initViewObj();
    };

    $scope.$watch('billResult.timeType',function(n,o){
      if(n === o) return;
      $scope.date = UpayBillResultQueryParam.initDate();
    },true);

    $scope.$watch('billResult.agencyType',function(n,o){
      if(n === o) return;
      $scope.selector = UpayBillResultSelecotor.setSelector(n.code);
    }); 
  }

  billResultCtrl.$inject = ['$scope','COREDATA','UpayBillResultSelecotor','UpayBillResultQueryParam','UpayBillResultViewObj'];

})();